import { Spin, TreeSelect } from 'antd';
import React from 'react';

import usePostList from './usePostList';

const { SHOW_ALL } = TreeSelect;

const AllSelectPost = ({ dataSource, cacheKey, getChildByOrganizationCode, ...restProps }) => {
    const [loading, treeData] = usePostList(dataSource, cacheKey);

    return (
        <Spin spinning={loading}>
            <TreeSelect
                treeNodeFilterProp="filterProp"
                treeData={treeData}
                showCheckedStrategy={SHOW_ALL}
                {...restProps}
                style={{ height: loading ? '35px' : 'auto' }}
            />
        </Spin>
    );
};

export default AllSelectPost;
